// STL includes
#include <vector>
#include <string>

// C includes

// Library includes
#include <cxxtest/TestSuite.h>

// Project includes
#include <EmitButton.h>
#include <Connector.h>
#include <PinControl.h>

using namespace std;

class IntegrationTestSuite: public CxxTest::TestSuite
{
  static const uint8_t signal_press = 1, signal_release = 2;
  static const int led_pin = 13, button_pin = 9;
  
  Updater* pUpdater;
  Connector* pConnector;
public:
  void setUp()
  {
    mock_time_reset();

    pUpdater = new Updater();
    pConnector = new Connector();
  }

  void tearDown( void )
  {
    delete pConnector;
    delete pUpdater;
    theLogger.setVerbose(false);
  }
  
  void testLedButton( void )
  {
    EmitButton button(*pConnector, button_pin, signal_press );
    PinControl led(*pConnector, led_pin, signal_release, signal_press );
    
    pUpdater->add(&button);
    button.begin();
    led.begin();
    led.listen(&button);
    
    thePins.hwSetDigital( button_pin, LOW );
    delay(30);
    pUpdater->update();
    
    TS_ASSERT_EQUALS( thePins.hwGetDigital(led_pin), HIGH );
  }
  void testLedButtonRelease( void )
  {
    EmitButton button(*pConnector, button_pin, signal_press, signal_release );
    PinControl led(*pConnector, led_pin, signal_release, signal_press );
    
    pUpdater->add(&button);
    button.begin();
    led.begin();
    led.listen(&button);
    
    thePins.hwSetDigital( button_pin, LOW );
    delay(30);
    pUpdater->update();

    thePins.hwSetDigital( button_pin, HIGH );
    delay(30);
    pUpdater->update();
    
    TS_ASSERT_EQUALS( thePins.hwGetDigital(led_pin), LOW );
  }
  
};
// vim:cin:ai:sts=2 sw=2 ft=cpp
